package com.lhc.nacosprovider.controller;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import com.lhc.nacosprovider.entity.Menu;
import com.lhc.nacosprovider.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName ProviderController
 * @Description:
 * @Author: asus
 * @CreateDate: 2020-11-24 11:10
 * @UpdateUser: asus
 * @UpdateDate: 2020-11-24 11:10
 * @UpdateRemark:
 * @Version: 1.0
 */
@RestController
public class ProviderController {

    @Value("${name}")
    private String name;

    @Autowired
    MenuService menuService;

    @RequestMapping("hello")
    public String hello() {
        return "hello  im provider ";
    }

    @GetMapping("/config")
    public String config() {
        return "nacos上获取配置name:" + name;
    }

    @GetMapping("/db")
    public List<Menu> list() {
        List<Menu> menus = menuService.allMenus();
        return menus;
    }

    @GetMapping("/tree")
    public List<Tree<String>> getTree() {
        return menuService.getTreeNode();
    }
}